<style type="text/css">
.layui-carousel > [carousel-item]::before {
	display:none;
}
</style>
<div class="layui-card">
	<div class="layui-card-header">
		<h2 class="header-title">采购订单管理</h2>
		<span class="layui-breadcrumb pull-right"> <a
			href="#!home_console">首页</a> <a><cite>采购订单管理</cite></a>
		</span>
	</div>
	<div class="layui-card-body">
		<div class="layui-form toolbar">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">开始日期：</label>
					<div class="layui-input-inline">
						<input type="text" name="beginTime"  id="beginTime"
							autocomplete="off" class="layui-input">
					</div>
				</div>

				<div class="layui-inline">
					<label class="layui-form-label">结束日期：</label>
					<div class="layui-input-inline">
						<input type="text" name="endTime" autocomplete="off" id="endTime"
							class="layui-input">
					</div>
				</div>


				<div class="layui-inline">
					<button id="user-btn-search"
						class="layui-btn layuiadmin-btn-useradmin" lay-submit
						lay-filter="LAY-front-search">
						<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
					</button>
					<button id="btn-reset" class="layui-btn icon-btn">
						<i class="layui-icon">&#x1006;</i>重置
					</button>
				</div>
			</div>

		</div>



		        <div class="layui-card-body">
          <div class="layui-row">
            <div class="layui-col-sm12">
                <div class="layui-carousel layadmin-carousel layadmin-dataview" data-anim="fade" lay-filter="LAY-index-pagetwo">
                  <div carousel-item id="LAY-index-pagetwo">
                    <div><i class="layui-icon layui-icon-loading1 layadmin-loading"></i></div>
                  </div>
                </div>
            </div>
          </div>
        </div>
	</div>
</div>

<script>
layui.use(['form',"admin", "carousel","echarts",'laydate'],
    function() {
        var e = layui.$,
        form = layui.form,
        laydate = layui.laydate,
        a = (layui.admin, layui.carousel),
        l = layui.element,
        t = layui.device();
       
        
        laydate.render({
            elem: '#beginTime',
            format: 'yyyy-MM'
        });
        laydate.render({
            elem: '#endTime',
            format: 'yyyy-MM'
        });
        
        //监听搜索
        form.on('submit(LAY-front-search)', function(data){
          var field = data.field;
          getData(field.beginTime,field.endTime);
        });
        
        
        e(".layadmin-carousel").each(function() {
            var l = e(this);
            a.render({
                elem: this,
                width: "100%",
                arrow: "none",
                interval: l.data("interval"),
                autoplay: l.data("autoplay") === !0,
                trigger: t.ios || t.android ? "click": "hover",
                anim: l.data("anim")
            })
        }),
        l.render("progress")

        var  a = (layui.carousel, layui.echarts),
        
        i = e("#LAY-index-pagetwo").children("div"),
        
        getData =function (beginTime,endTime){
          layui.admin.req("service/shopBuy/shopBuy", {beginTime: beginTime,endTime:endTime}, function(ret) {
              if (ret.code == 1) {
            	 var t = [{
            		  tooltip: {
                          trigger: "item"
                      },
                      legend: {
                          data: ["采购总值"]
                      },
            		  xAxis: [{
                          type: "category",
                          name: "门店",
                          data:ret.data.xAxis
                      }],
                      yAxis: [{
                          type: "value",
                          name: "采购总值(元)",
                          axisLabel: {
                              formatter: "{value} 元"
                          }
                      }],
                      series: [{
                    	  name: "采购总值",
                          type: "bar",
                          barMinHeight: 0,          // 最小高度改为0
                          barWidth : 50,
                          data: ret.data.seriesleft
                      }]
                  }];
                  l[0] = a.init(i[0], layui.echartsTheme);
                  l[0].setOption(t[0]);
              }
          }, "post");
      };
        i[0] && getData(null,null)
      })
</script>